<template>
    <div>
        <h2>展示新闻</h2>
         <table>
            <tr>
                <td>id</td>
                <td>title</td>
                <td>content</td>
                <td>操作</td>
            </tr>     
            <tr v-for="i in items" :key="i.id">
                <td>{{i.id}}</td>
                <td>{{i.title}}</td>
                <td>{{i.content}}</td>
                <td @click="sub(i.id)">评论</td>
            </tr>
        </table>   
    </div>    
</template>

<script>
import axios from "axios"
export default {
    name:"showxin",
    data() {
        return {
            items:"",
        }
    },
    methods:{
        get_xin(){
            axios({
                url:"http://127.0.0.1:8000/app04/xin/",
                method:"get",
            }).then(res=>{
                console.log(res.data)
                this.items = res.data.data
            })
        },
        sub(id){
            this.$router.push({path:"/ppll/"+this.id})
        },
    },
    created(){
        this.get_xin()
    }
}
</script>

<style>

</style>
